import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:patient_flutter/screen/splash_screen/splash_screen_controller.dart';
import 'package:patient_flutter/utils/asset_res.dart';

class SplashScreen extends StatelessWidget {
  const SplashScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(SplashScreenController());
    return Scaffold(
      body: GetBuilder(
          init: controller,
          initState: (state) {
            controller.prefData();
          },
          builder: (_) {
            return Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Image(
                    image: const AssetImage(AssetRes.doctor3),
                    height: Get.height,
                    width: Get.width,
                    fit: BoxFit.cover),
                _bottomArea(controller),
              ],
            );
          }),
    );
  }

  Widget _bottomArea(SplashScreenController controller) {
    return Expanded(
      child: Container(
        margin: const EdgeInsets.symmetric(horizontal: 15),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Spacer(),
            const SizedBox(
              height: 10,
            ),
            const Spacer(),
            GetBuilder(
                init: controller,
                builder: (context) {
                  return controller.isLoading
                      ? const Center(
                          child: CircularProgressIndicator(),
                        )
                      : const SizedBox();
                }),
            const Spacer(),
          ],
        ),
      ),
    );
  }
}
